unit BelieveSelectFrm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, Grids, DBGrids, StdCtrls, Mask, RzEdit, RzBtnEdt, Buttons,
  DB, DBClient, BelieveRuleUnt;

type
  TBelieveSelectForm = class(TForm)
    pnlTop: TPanel;
    dbgrdBelieve: TDBGrid;
    Label1: TLabel;
    rzbtnedtName: TRzButtonEdit;
    btnEnter: TBitBtn;
    btnCancel: TBitBtn;
    cdsVBelieve: TClientDataSet;
    cdsVBelieveID: TWideStringField;
    cdsVBelieveName: TWideStringField;
    cdsVBelieveSex: TWideStringField;
    cdsVBelieveMobile: TWideStringField;
    cdsVBelieveServeTypeName: TWideStringField;
    cdsVBelieveBaptism: TWideStringField;
    dsBelieve: TDataSource;
    procedure FormCreate(Sender: TObject);
    procedure rzbtnedtNameButtonClick(Sender: TObject);
  private
    { Private declarations }
    procedure LoadDataSource();
  public
    { Public declarations }
  end;

var
  BelieveSelectForm: TBelieveSelectForm;

implementation

{$R *.dfm}

procedure TBelieveSelectForm.FormCreate(Sender: TObject);
begin
  self.LoadDataSource();
end;

procedure TBelieveSelectForm.LoadDataSource;
var
  BelieveRule: TBelieveRule;
begin
  BelieveRule := TBelieveRule.Create();
  try
    cdsVBelieve.DisableControls();
    cdsVBelieve.Close();
    cdsVBelieve.Data := BelieveRule.GetBelieveSelectData();
    cdsVBelieve.Open();
    cdsVBelieve.EnableControls();
  finally
    FreeAndNil(BelieveRule);
  end;
end;

procedure TBelieveSelectForm.rzbtnedtNameButtonClick(Sender: TObject);
begin
  if rzbtnedtName.Text = '' then
  begin
    cdsVBelieve.Filtered := False;
  end
  else
  begin
    cdsVBelieve.Filtered := False;
    cdsVBelieve.Filter := 'Name like ' + QuotedStr('%' + rzbtnedtName.Text + '%');
    cdsVBelieve.Filtered := True;
  end;
end;

end.
